package com.chapter11.enum_;

/**
 * @author 宋鑫宇
 * @version 1.0
 * 枚举类:一个一个列举出来的类
 * 枚举属于一种特殊的类，里面包含一组有限的特定的对象。
 * 枚举的两种实现方式
 * 1.自定义类实现枚举
 * 2.使用enum关键字实现枚举
 */

/**
 * 自定义实现枚举
 */
public class Enumeration01 {
    public static void main(String[] args) {
        System.out.println(Season.AUTUMN);
    }
}
//演示自定义枚举的实现
class Season {
    private String name;
    private String desc;
    public final static Season SPRING = new Season("春天","温暖");
    public final static Season WINTER = new Season("冬天","寒冷");
    public final static Season AUTUMN = new Season("秋天","凉爽");
    public final static Season SUMMER = new Season("夏天","炎热");
    //第一步，构造器私有化,防止直接被new
    //第二部，去掉set方法，防止属性被修改
    //在类的内部直接创建固定的对象,static的对象
    //优化，可以加入final关键字优化
    private Season(String name, String desc) {
        this.name = name;
        this.desc = desc;
    }

    public String getName() {
        return name;
    }

    public String getDesc() {
        return desc;
    }

    @Override
    public String toString() {
        return "Season{" +
                "name='" + name + '\'' +
                ", desc='" + desc + '\'' +
                '}';
    }
}
